local skynet = require "skynet"
local socket = require "skynet.socket"
skynet.start(function()
    local addr = "0.0.0.0:8001"
    skynet.error("listen " .. addr)
    local lID = socket.listen(addr)
    assert(lID)
    socket.start(lID, function(cID, addr)
        skynet.error(addr .. " accepted")
        -- 当前服务开始使用套接字
        socket.start(cID)
        local str = socket.read(cID)
        if (str) then
            socket.write(cID, string.upper(str))
        end
        -- 不想使用了，这个时候遗弃控制权
        socket.abandon(cID)

        skynet.newservice("socketagent", cID, addr) -- 代理服务不变
    end)
end)

-- 转移控制权
